Liberty BASIC Financial Functions

by Tom Nally Steelweaver52@aol.com


NL127 Home

Beginning Programming X

Multiple Listbox Arrays

Video Capture in LB

Images on Statictext

Bulk File Renamer

Dynamic Web Pages

Animated Titles

Financial Functions

::::::::::::::::::::::::::::::::::::::::::::::::::::

Submission Guildlines

Newsletter Help

Index

Introduction

Financial functions are functions which allow you to calculate the following:

These types of functions are very easy to construct in [Liberty BASIC]. With financial functions, LB programmers can create their own customized car payment calculators, investment projecting programs, and things like that!

Comparing Financial Alternatives and the "Time Value" of Money

To understand the time value of money, let us consider the following hypothetical situation:

A benefactor wants to give you a financial gift. In fact, he is offering you two alternatives from which to choose. The two alternatives are these:

  1. You may either accept $10,000 from the benefactor today; or

  2. You may accept $15,000 from the benefactor seven years from today.

Which of these two alternatives would you choose?

This seems like a difficult question. How can we compare $10,000 today with $15,000 seven years from today? That's a little bit like comparing apples and oranges. Fortunately, we need not guess at the answer. Long ago, economists and financiers figured out ways to answer these types of questions rationally. First, understand that the reality that financial interest changes the value of money over time.

For instance, if you used the $10,000 today to buy a bond that pays 5% interest annually, here is how the bond would change in value over the ensuing seven years:

In one year, the bond would be worth $10,000 x (1 + 0.05) = $10,500.

In two years, the bond would be worth $10,500 x (1 + 0.05) = $11,025.

In three years, the bond would be worth $11,025 x (1 + 0.05) = $11,576.

In four years, the bond would be worth $11,576 x (1 + 0.05) = $12,155.

In five years, the bond would be worth $12,155 x (1 + 0.05) = $12,763.

In six years, the bond would be worth $12,763 x (1 + 0.05) = $13,401.

In seven years, the bond would be worth $13,401 x (1 + 0.05) = $14,071.

The analysis above shows that the $10,000 gift received today will only have a value of $14,071 in seven years. Since the other alternative has a value of $15,000 in seven years, we know unambiguously that the second alternative is the better one.

To successfully resolve this problem, we've used financial analysis. We have calculated the future value of $10,000 in seven years at 5% interest. This gave us a rational way to compare the value of $10,000 today with $15,000 seven years from today. Using 5% interest as our annual mark up, we've found that $15,000 seven years from today is more valuable than $10,000 today.

That's an extremely important finding. Of course, we arrived at the result using "the long way". A shorter way to get the same result is found by recognizing that we are multiplying the original "principle" ($10,000) by 1.05 over and over again. The shortcut to the solution looks like this:

    $10,000 x (1+ 0.05)^7 = $14,071

That's a lot easier, isn't it? In addition to being easier, it also provides the general equation for the Future Value of a fixed investment compounded over a period of time! The equation for Future Value, in general terms, looks like this:

    FV = PV * (1 + i)^n

where

    FV = the Future Value of the investment
    PV = the Present Value of the investment
    i  = the interest rate over the life of the investment
    n  = the number of periods over which the interest rate is compounded

With our new appreciation for the time value of money, it's time to break out the Liberty BASIC Financial Functions!

FV() - the Future Value Function

The Future Value Function:

    Function FV(PV,i,n)
        FV = PV * (1 + i)^n
    end function

    'where...
    'FV = the Future Value of the investment
    'PV = the Present Value of the investment
    'i  = the interest rate over the life of the investment
    'n  = the number of periods over which the interest rate is compounded

Example: I have a lump sum of $6,000 that I plan to invest at an interest rate of 4.5% over 8 years. What will be the value of my investment at the end of 8 years?

Answer:

    investmentValue = FV(6000, 0.045,8)

This will return a value of $8,532.60.

PV() - the Present Value Function

The Present Value Function is the inverse of the Future Value function. The Present Value Function is used to answer these types of questions:

How much do I need to invest today at 6.5% in order to have $12,000 six years from today?

The answer to that question is the Present Value of $12,000 six years from today.

    Function PV(FV,i,n)
        PV = FV / ((1 + i)^n)
    end function

    'where...
    'PV = the Present Value of the investment
    'FV = the Future Value of the investment
    'i  = the interest rate over the life of the investment
    'n  = the number of periods over which the interest rate is compounded

To answer the question posed above,

    todaysValue = PV(12000, 0.065,6)

This will return a value of $8,224.01. This means that if you invest $8.224.01 today at 6.5% annual interest, it will achieve a value of $12,000 at the end of six years.

PMT() - the Payment Function

The Payment Function returns the periodic payment that can be generated by a lump sum invested today, given a fixed number of payment periods and a constant interest rate. This function is also used to calculate home mortgage payments and car payments

    Function PMT(PV,i,n)
        PMT = PV * (i*(1+i)^n)/((1+i)^n - 1)
    end function

    'where...
    'PV  = the Present Value of the investment, sometimes referred to as the "principle"
    'PMT = the periodic payment that the investment can generate over n periods at i interest
    'i   = the interest rate over the life of the investment
    'n   = the number of periods over which the payment is payed out

Example 1: My uncle has given me a lump sum of $5,000 which I will put in a savings account earning 3.5% interest. I would like to draw equal amounts from this account each month until the entire amount is used up in 24 months. How much money can I withdraw each month?

    myWithdrawal = PMT(5000,0.035/12,24)

This will return a value of $216.01. Note the following about this result. The amount that you are able to withdraw is greater than just $5,000 divided by 24, which is $208.33. This is because the amount remaining in the account after you make a withdrawal continues to earn money at 3.5% annual interest, or 3.5%/12 monthly interest.

Example 2: You purchase an automobile for $17,000. You provide a $5,000 down payment, and you borrow the remaining $12,000. A bank loans you this amount at 6.25% interest to be paid back in equal amounts over the next 60 months (five years). What is your monthly car note?

    myCarNote = PMT(12000,0.0625/12,60)

This will return a value of $233.39. That will be your monthly car payment over the next five years.

FofA() - the F of A Function

The F of A Function will return the Future Value of a series of equal periodic payments over a fixed number of periods at a fixed interest rate.

    Function FofA(PMT,i,n)
        FofA = PMT * ((i + 1)^n - 1) / i
    end function

    'where...
    'FofA = the Future Value of the series of periodic payments after n periods
    'PMT  = the periodic payment delivered to the account over n periods
    'i    = the interest rate applied to the account over n periods
    'n    = the number of periods during which the payment is delivered to the account

DGBYACS.bas

Example: For my nephew's college fund, I plan to deposit $50 per month for ten years in a savings account that earns 4.5% per year. How much money will the account have after ten years?

    futureAccountValue = FofA(50,0.045/12,120)

This will return a value of $7,559.90. Note that this value is substantially larger than just $50 x 120 months, which is equal to $6,000. Note also that I had to convert the yearly interest rate (4.5%) into an equivalent monthly interest rate (4.5%/12) because the period was defined as a month.

Daddy's Gonna Buy You A Car, Sugar!

I've identified four simple financial functions above, but there are many more that are useful. Instead of describing them, however, I am providing a small program to calculate a monthly car payment. This program is included in the zip archive as DGBYACS.bas, pronounced "D-G-B Yacks". It's an acronymn for Daddy's Gonna Buy You A Car, Sugar! It uses the PMT() Function described above, and is very easy to use. DGBYACS.bas is released as open source.

--- Tom Nally


NL127 Home

Beginning Programming X

Multiple Listbox Arrays

Video Capture in LB

Images on Statictext

Bulk File Renamer

Dynamic Web Pages

Animated Titles

Financial Functions

::::::::::::::::::::::::::::::::::::::::::::::::::::

Submission Guildlines

Newsletter Help

Index